package com.recipedb.recipedb.service.impl;

import com.recipedb.recipedb.entity.Category;
import com.recipedb.recipedb.entity.Ingredient;
import com.recipedb.recipedb.repository.CategoryRepository;
import com.recipedb.recipedb.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Optional;

@Service
public class CategoryServiceImpl implements CategoryService {

    @Autowired
    private CategoryRepository repository;

    @Override
    public Category save(Category entity) {
        return repository.save(entity);
    }

    @Override
    public void deleteById(Long id) {
        repository.deleteById(id);
    }

    @Override
    public Optional<Category> findById(Long id) {
        return repository.findById(id);
    }

    @Override
    public List<Category> findAll() {
        return repository.findAll();
    }

    @Override
    public List<Category> findByRecipeId(Long recipeId) {
        return repository.findByRecipeId(recipeId);
    }
}
